<?php

/**
 * Base project form.
 * 
 * @package    venteunique
 * @subpackage form
 * @author     Your name here 
 * @version    SVN: $Id: BaseForm.class.php 20147 2009-07-13 11:46:57Z FabianLange $
 */
class BaseForm extends sfFormSymfony
{

  public function getYesNo(){
    return array(  1 => 'Oui', 0 => 'Non' );
  }

  
  public function getDefaultYears(){
    $years = array();
    for ($i=date('Y') - 50 ; $i <= date('Y')-1 ; $i++) { 
      $years[$i] = $i;
    }
    return $years;
  }
  

  public function getDefaultDateWidget($years = false){
    $years = !$years ? $this->getDefaultYears() : $years;
    $dateWidget = new sfWidgetFormI18nDate(array(
            'years'			=> $years,
            'format' 		=> '%day%/%month%/%year%',
            'month_format' 	=> 'short_name',
            'culture' 		=> 'fr'));
    return $dateWidget;
  }
  
 public function getDefaultYearWidget($years = false){
    $years = !$years ? $this->getDefaultYears() : $years;
    $dateWidget = new sfWidgetFormI18nDate(array(
            'years'			=> $years,
            'format' 		=> '%year%',
            'month_format' 	=> 'short_name',
            'culture' 		=> 'fr'));
    return $dateWidget;
  }
  

  public function addCSRFProtection($secret = null)
  {
    parent::addCSRFProtection($secret);
    $this->getValidator(self::$CSRFFieldName)->setMessage('csrf_attack', 'Session expirée : veuillez rafraîchir la page.');
  }

  
}
